

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="zh" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="zh" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Visualization &mdash; Optuna 1.4.0 文档</title>
  

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  
  
  

  
  <script type="text/javascript" src="../../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />
    <link rel="index" title="索引" href="../../genindex.html" />
    <link rel="search" title="搜索" href="../../search.html" />
    <link rel="next" title="Pruners" href="../pruners.html" />
    <link rel="prev" title="Trial" href="trial.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> Optuna
          

          
          </a>

          
            
            
              <div class="version">
                1.4.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">目录</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../installation.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../tutorial/index.html">教程</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../core.html">Core</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli.html">Command Line Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="../distributions.html">Distributions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../exceptions.html">Exceptions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../importance.html">Hyperparameter Importance</a></li>
<li class="toctree-l2"><a class="reference internal" href="../integration.html">Integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logging.html">Logging</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Multi-objective</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="samplers.html">Samplers</a></li>
<li class="toctree-l3"><a class="reference internal" href="study.html">Study</a></li>
<li class="toctree-l3"><a class="reference internal" href="trial.html">Trial</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">Visualization</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../pruners.html">Pruners</a></li>
<li class="toctree-l2"><a class="reference internal" href="../samplers.html">Samplers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../storages.html">Storages</a></li>
<li class="toctree-l2"><a class="reference internal" href="../structs.html">Structs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../study.html">Study</a></li>
<li class="toctree-l2"><a class="reference internal" href="../trial.html">Trial</a></li>
<li class="toctree-l2"><a class="reference internal" href="../visualization.html">Visualization</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq.html">常见问题</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">Optuna</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../index.html">API Reference</a> &raquo;</li>
        
          <li><a href="index.html">Multi-objective</a> &raquo;</li>
        
      <li>Visualization</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../_sources/reference/multi_objective/visualization.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <span class="target" id="module-optuna.multi_objective.visualization"></span><div class="section" id="visualization">
<h1>Visualization<a class="headerlink" href="#visualization" title="永久链接至标题">¶</a></h1>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p><a class="reference internal" href="#module-optuna.multi_objective.visualization" title="optuna.multi_objective.visualization"><code class="xref py py-mod docutils literal notranslate"><span class="pre">visualization</span></code></a> 模块通过 plotly 来绘制图表，但是  <a class="reference external" href="https://github.com/jupyterlab/jupyterlab">JupyterLab</a>  不能直接渲染这些图表。要显示图表的话，请照 <a class="reference external" href="https://github.com/jupyterlab/jupyterlab">JupyterLab</a> 的 <a class="reference external" href="https://github.com/plotly/plotly.py#jupyterlab-support-python-35">installation guide</a> 办。</p>
</div>
<dl class="py function">
<dt id="optuna.multi_objective.visualization.plot_pareto_front">
<code class="sig-prename descclassname">optuna.multi_objective.visualization.</code><code class="sig-name descname">plot_pareto_front</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">study</span><span class="p">:</span> <span class="n"><a class="reference internal" href="study.html#optuna.multi_objective.study.MultiObjectiveStudy" title="optuna.multi_objective.study.MultiObjectiveStudy">optuna.multi_objective.study.MultiObjectiveStudy</a></span></em>, <em class="sig-param"><span class="n">names</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>List<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.8)">str</a><span class="p">]</span><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; plotly.graph_objs._figure.Figure<a class="reference internal" href="../../_modules/optuna/multi_objective/visualization/_pareto_front.html#plot_pareto_front"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#optuna.multi_objective.visualization.plot_pareto_front" title="永久链接至目标">¶</a></dt>
<dd><p>返回一个 study 的帕累托前沿面。</p>
<p class="rubric">示例</p>
<p>下面的代码片段展示来如何绘制一个 study 的帕累托前沿面。</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">optuna</span>

<span class="k">def</span> <span class="nf">objective</span><span class="p">(</span><span class="n">trial</span><span class="p">):</span>
   <span class="n">x</span> <span class="o">=</span> <span class="n">trial</span><span class="o">.</span><span class="n">suggest_float</span><span class="p">(</span><span class="s2">&quot;x&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
   <span class="n">y</span> <span class="o">=</span> <span class="n">trial</span><span class="o">.</span><span class="n">suggest_float</span><span class="p">(</span><span class="s2">&quot;y&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>

   <span class="n">v0</span> <span class="o">=</span> <span class="p">(</span><span class="mi">4</span> <span class="o">*</span> <span class="n">x</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="mi">4</span> <span class="o">*</span> <span class="n">y</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span>
   <span class="n">v1</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="mi">5</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="p">(</span><span class="n">y</span> <span class="o">-</span> <span class="mi">5</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span>
   <span class="k">return</span> <span class="n">v0</span><span class="p">,</span> <span class="n">v1</span>

<span class="n">study</span> <span class="o">=</span> <span class="n">optuna</span><span class="o">.</span><span class="n">multi_objective</span><span class="o">.</span><span class="n">create_study</span><span class="p">([</span><span class="s2">&quot;minimize&quot;</span><span class="p">,</span> <span class="s2">&quot;minimize&quot;</span><span class="p">])</span>
<span class="n">study</span><span class="o">.</span><span class="n">optimize</span><span class="p">(</span><span class="n">objective</span><span class="p">,</span> <span class="n">n_trials</span><span class="o">=</span><span class="mi">50</span><span class="p">)</span>

<span class="n">optuna</span><span class="o">.</span><span class="n">multi_objective</span><span class="o">.</span><span class="n">visualization</span><span class="o">.</span><span class="n">plot_pareto_front</span><span class="p">(</span><span class="n">study</span><span class="p">)</span>
</pre></div>
</div>
<iframe src="../../_static/plot_pareto_front.html" width="100%" height="500px"
frameborder="0"></iframe><dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>study</strong> -- <a class="reference internal" href="study.html#optuna.multi_objective.study.MultiObjectiveStudy" title="optuna.multi_objective.study.MultiObjectiveStudy"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiObjectiveStudy</span></code></a> 对象，其trial 的目标函数值都将被绘制出来。</p></li>
<li><p><strong>names</strong> -- 作为轴线标题的目标函数名。如果设置成 <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.8)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a> 的话，Optuna 将采用  &quot;Objective {objective_index}&quot;。</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">plotly.graph_objs.Figure</span></code> 对象。</p>
</dd>
<dt class="field-odd">引发</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(在 Python v3.8)"><strong>ValueError</strong></a> -- 如果  <code class="docutils literal notranslate"><span class="pre">study</span></code> 的目标函数个数不是 2 或者 3 的话。</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>在 v2.0.0 中作为试验性特性引入，在未来版本中，该接口可能在没有预先告知的情况下被改变。参考 <a class="reference external" href="https://github.com/optuna/optuna/releases/tag/v2.0.0">https://github.com/optuna/optuna/releases/tag/v2.0.0</a>.</p>
</div>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../pruners.html" class="btn btn-neutral float-right" title="Pruners" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="trial.html" class="btn btn-neutral float-left" title="Trial" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Optuna Contributors.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
    <a href="../../privacy.html">Privacy Policy</a>.
     


</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-55135190-8', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>